<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page 
  language="java"
  contentType="text/html; charset=ISO-8859-1"
  import				="com.epro.standard.frontend.util.FileInfoUtil,
                      java.util.Vector,
                      java.util.Date,
                      java.text.SimpleDateFormat,
                      java.util.Locale,
                      com.softplus.carrefour.hd.bltier.admin.ICFHDSystemViewer,
                      com.softplus.carrefour.hd.bltier.admin.CFHDSystemManage,
                      com.softplus.carrefour.hd.CFHDSystem,
                      com.softplus.carrefour.hd.bltier.admin.ICFHDModuleViewer,
                      com.softplus.carrefour.hd.bltier.admin.CFHDModuleManage,
                      com.softplus.carrefour.hd.bltier.admin.ICountryViewer,
                      com.softplus.carrefour.hd.bltier.admin.CountryManage,
                      com.softplus.carrefour.hd.bltier.entity.*,
                      com.softplus.carrefour.hd.bltier.util.DateUtil,
                      com.softplus.carrefour.hd.bltier.admin.UserLevelManage,
                      com.softplus.carrefour.hd.bltier.entity.*,
                      com.softplus.carrefour.hd.bltier.admin.IUserLevelViewer,
                      com.softplus.carrefour.hd.bltier.admin.UserLevelManage,
                      com.softplus.carrefour.hd.bltier.entity.Country"
%>
<%
  
%>
<HTML xmlns:epro>
<%@  taglib uri="/WEB-INF/HeadTag.tld" prefix="head"%>  
<%@  taglib uri="/WEB-INF/TextfieldTag.tld" prefix="textfield"%>
<%@ taglib uri="/WEB-INF/CalendarTag.tld" prefix="calendar"%>
<%@ taglib uri="/WEB-INF/ErrorTag.tld" prefix="error"%>
<head:Head
	author="Pomme" 
  import="calendar,textfield,error"
  jsFile="../script/spTitleRefresh.js,../script/checkValidData.js,../script/convertDataType.js,../script/dateCalendar.js,../script/Alert.js" 
	styleFile="../theme/defaultTheme.css,../theme/CFRLTheme.css" 
	title="List of Cases Opened for More Than X Day(s)">
</head:Head>

<%  
		String selectWidth		= "500";
		    
    FileInfoUtil	fileInfoUtil 			= (session.getAttribute("fileInfoUtil")!=null?(FileInfoUtil) session.getAttribute("fileInfoUtil"):new FileInfoUtil());
    fileInfoUtil.setMenuIDCode("CFHDRPMT04 ") ;
    fileInfoUtil.setMenuName("List of Cases Opened for More Than X Day(s)") ;
    fileInfoUtil.setMenuDesc("To list the cases opened for more than specific day") ;
    fileInfoUtil.setMasterWording("List of Cases Opened for More Than X Day(s)") ;
    
    String backURL			= "/CFRL/CFRLWEBMN01.jsp?page=1" ;
    String backClick		= "location='" + backURL + "'" ; 
       
    // === define object ===
		ICountryViewer					countryManage	=	(CountryManage)CFHDSystem.getControlClass("COUNTRY");    
    // === define vector ===
		Vector	systemVector	=	new Vector(0);
		Vector	moduleVector	=	new Vector(0);
		Vector	countryVector	=	new Vector(0);
         
    //Current Date    
    SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); 
    //get User,UserLevel
    String user =  request.getParameter("uid");
    System.out.println("====================user_ID===================" + user);      
    UserLevelManage umanage = new UserLevelManage();
    String userLevel = "";    
       
    userLevel = umanage.getUserLevelByUserID(user);
    System.out.println("====================user_Level===================" + userLevel); 
   
    if(userLevel == null)
    {
      userLevel = "";
    }    
    
    DateUtil dateU = new DateUtil();
    
    String countryID = "";
    
    System.out.println("====================Time===================" + formatter.format(dateU.getLocalDate(user)));
    System.out.println("====================user_ID===================" + user);      
    System.out.println("====================user_Level===================" + userLevel);      
      
%>

  <script type="text/javascript">  
    if(<%=userLevel.equals("")%>)
    {
      showOInfoDialog("Authentication Failed!", "You might not be authorized in E-Helpdesk System. Please Contact Administrator.\n click OK  to continue.", "OK");
      parent.location =parent.location;
    } 
  </script>
  <body>  
    <%=fileInfoUtil.MasterHeadTable()%>
    <script src="../script/spToolbar.js" type="text/javascript"></script>    
<FORM name="frm">
<INPUT type="hidden" name="user_id" value=<%=user%>>    
<TABLE align="center" border="0" width="100%" cellpadding="0" cellspacing="0">
        <TR>
          <TD valign="top" align="left" style="padding-left:15px;">
            <IMG SRC= "../images/icon/toolbar/nBackToMenu.gif" alt="Back To Menu" onclick="backTomenu();" Style="cursor:hand"
              onmouseover="Javascript: this.src='../images/icon/toolbar/oBackToMenu.gif' " 
              onmouseout="Javascript: this.src='../images/icon/toolbar/nBackToMenu.gif' ">      
          </TD>
        </TR>
</TABLE>

<TABLE align="center" border="0" bordercolor="red" cellpadding="1" cellspacing="1">
	<TR>
		<TD class="titleFont">Open Case Country : </TD>
    
    <%if(userLevel.equals(UserLevel.ADMIN)||userLevel.equals(UserLevel.LEVEL_2_AMS_ZONE_ASIA)||userLevel.equals(UserLevel.LEVEL_3_AMS_BANGKOK)||userLevel.equals(UserLevel.PRODUCTION_STAFF))
    {%>
		<TD>      
      <SELECT name="country" style="width: 220px">
      <OPTION value="ALL">All</OPTION>
		
    <%
				countryVector	=	countryManage.getAllCountry();
				if (countryVector != null)
				{		for (int m=0;m<countryVector.size();m++)
						{		
              Country	countryEntity	=	(Country)countryVector.elementAt(m);
              countryID = countryEntity.getCountryId();
      %>
                <OPTION value="<%=countryEntity.getCountryId()%>"><%=countryEntity.getCountryName()%></OPTION>
		<%}%>
	<%}%>
			</SELECT>
		</TD>
    <%}%>    
    <%if((!(userLevel.equals(UserLevel.ADMIN)))&&(!(userLevel.equals("")))&&(!(userLevel.equals(UserLevel.LEVEL_2_AMS_ZONE_ASIA)))&&(!(userLevel.equals(UserLevel.LEVEL_3_AMS_BANGKOK)))&&(!(userLevel.equals(UserLevel.PRODUCTION_STAFF)))) {
      UserLevel userL = (UserLevel)umanage.getUserLevel(user);      
      UserAccount userAcc = (UserAccount)userL.getUserAccount();
      Country country = (Country)userAcc.getCountry();
      String c_id = (String)country.getCountryId();
      String c_name = (String)country.getCountryName();
    %>
      <TD>
          <SELECT name="country" style="width: 220px" >
          <OPTION value="<%=c_id%>" disabled="disabled"><%=c_name%></OPTION>        
        </SELECT>
      </TD>
    <%}%>
    
	</TR>
	<TR>
		<TD class="titleFont">
      Case Type : 
    </TD>
		<TD class="titleNormal">      
      <INPUT type="checkbox" name="P1" value="P1"> User Question(P1)      
    </TD>
	</TR>
	<TR>
		<TD></TD>
		<TD class="titleNormal">
      <INPUT type="checkbox" name="P2" value="P2"> Problem Report(P2)
    </TD>
	</TR>
	<TR>
		<TD></TD>
		<TD class="titleNormal">
      <INPUT type="checkbox" name="P3" value="P3"> Change Request(P3)
    </TD>
	</TR>	
	 <INPUT type="hidden" name="P4" value="">
<!-- 
	<TR>
		<TD></TD>
		<TD class="titleNormal">
      <INPUT type="checkbox" name="P4" value="P4"> Service Request(P4)
    </TD>
	</TR>
	<TR>
-->
		<TD class="titleFont">
      Opened for More Than :
    </TD>
		<TD>
      <textfield:textfield onkeyup="noInteger();" dataType="integer" name="day" maxLength="7" width="155" value="0"></textfield:textfield>
    </TD>
		<TD class="titleFont"> day(s)</TD>
	</TR>
  <TR>
		<TD class="titleFont">Open Case Date </TD>
	</TR>
  <TR>
    <TD class="titleFont">From : </TD>
		<TD>
      <textfield:textfield name="fromDate" readonly="yes" value= "<%=formatter.format(dateU.getLocalDate(user))%>" dataType="date" label1="From Date" label2="To Date" isBetween="yes" firstValue="yes" compareWith="toDate" condition="<="></textfield:textfield>
        <IMG src="../images/icon/calendar/nCalendar.gif" onmouseover="this.src='../images/icon/calendar/oCalendar.gif'" onmouseout="this.src='../images/icon/calendar/nCalendar.gif'" alt="Calendar" style='cursor: hand' onclick="CalendarFromDate()">
    </TD>
		<TD class="titleFont">To : </TD>
		<TD>
      <textfield:textfield name="toDate" readonly="yes" value= "<%=formatter.format(dateU.getLocalDate(user))%>" dataType="date" label1="From Date" label2="To Date" isBetween="yes" firstValue="no" compareWith="fromDate" condition="<=" ></textfield:textfield>
        <IMG src="../images/icon/calendar/nCalendar.gif" onmouseover="this.src='../images/icon/calendar/oCalendar.gif'" onmouseout="this.src='../images/icon/calendar/nCalendar.gif'" alt="Calendar" style='cursor: hand' onclick="CalendarToDate()"> 
    </TD>
  </TR>
  <TR>
    <TD></TD>
    <TD align="center">     
    </TD>
  </TR>    
  </TABLE>    
  <TABLE align="center" border="0" bordercolor="red" cellpadding="0" cellspacing="0"> 
    <TR>
      <TD class="titleFont">
        <center>
          <INPUT type="button" value="View Report" onclick="ViewReport()">                   
        </center>        
        </TD>
        <TD>        
        <INPUT type="button" value="Export To Excel" onclick="ViewExcelReport()">
        </TD>      
    </TR>    
    
  </TABLE>
  <TABLE align="center" border="0" bordercolor="red" cellpadding="0" cellspacing="0">
    <TR>
      <TD>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;
      </TD>
      <TD style="font-family:Verdana, Geneva, Arial, Helvetica, sans-serif; font-size:11px; font-weight:bold; text-align:left;">
        <Font color="red">
          <BR>
          *Please Note: To display report in the correct format,<BR>
          &nbsp;&nbsp;&nbsp;please select 'Open' button to view report <BR>
          &nbsp;&nbsp;&nbsp;before save it as an excel file        
         </Font>
      </TD>
    </TR>
  </TABLE>
</FORM>

<SCRIPT language="javascript">
  function CalendarFromDate()
	{
		document.all.fromDate.focus();
		document.all.fromDate.value = window.showModalDialog('Calendar.jsp','window ','status:no;dialogHeight:231px;dialogWidth:262px;scroll:no');	
		if(document.all.fromDate.value == "undefined")
		{	showOWarningDialog("warning","<B>Please Input Open Case Date From again","OK");
			document.all.fromDate.value='';}
        else {document.all.fromDate.focus();}
	}
  
	function CalendarToDate()
	{		
		document.all.toDate.value = window.showModalDialog('Calendar.jsp','window ','status:no;dialogHeight:231px;dialogWidth:262px;scroll:no');	
		if(document.all.toDate.value == "undefined")   
		{		document.all.toDate.value = "";
				showOWarningDialog("warning","<B>Please Input Open Case Date To again","OK");
				document.all.toDate.focus();				
		}
		else {document.all.toDate.focus();}
	}
  
  function ViewReport()
  {    
  
   if(( frm.P1.checked==false )&&( frm.P2.checked==false )&&( frm.P3.checked==false )&&( frm.P4.checked==false ))
   {
      showOWarningDialog("warning","<B>Please Select Case Type","OK");      
   } 
   else
   {
      if((document.all.fromDate.value == "")&&(( frm.P1.checked==true )||( frm.P2.checked==true )||( frm.P3.checked==true )||( frm.P4.checked==true )))
      {
        showOWarningDialog("warning","<B>Please Specify Open Case Date From","OK");  
      }
      else if((document.all.toDate.value == "")&&(( frm.P1.checked==true )||( frm.P2.checked==true )||( frm.P3.checked==true )||( frm.P4.checked==true )))
      {
        showOWarningDialog("warning","<B>Please Specify Open Case Date To","OK");  
      }
      else
      {
        var url = "CFHDRPRP04.jsp?country=" + frm.country.value + "&p1=" + frm.P1.checked + "&p2=" + frm.P2.checked + "&p3=" + frm.P3.checked + "&p4=" + frm.P4.checked + "&day=" + frm.day.value + "&from=" + frm.fromDate.value + "&to=" + frm.toDate.value + "&uid=" + frm.user_id.value;
        window.location.href = url;
      }
   }   
  }
  
  function ViewExcelReport()
  {    
  
   if(( frm.P1.checked==false )&&( frm.P2.checked==false )&&( frm.P3.checked==false )&&( frm.P4.checked==false ))
   {
      showOWarningDialog("warning","<B>Please Select Case Type","OK");      
   } 
   else
   {
      if((document.all.fromDate.value == "")&&(( frm.P1.checked==true )||( frm.P2.checked==true )||( frm.P3.checked==true )||( frm.P4.checked==true )))
      {
        showOWarningDialog("warning","<B>Please Specify Open Case Date From","OK");  
      }
      else if((document.all.toDate.value == "")&&(( frm.P1.checked==true )||( frm.P2.checked==true )||( frm.P3.checked==true )||( frm.P4.checked==true )))
      {
        showOWarningDialog("warning","<B>Please Specify Open Case Date To","OK");  
      }
      else
      {
        var url = "CFHDRPRP04_excel.jsp?country=" + frm.country.value + "&p1=" + frm.P1.checked + "&p2=" + frm.P2.checked + "&p3=" + frm.P3.checked+ "&p4=" + frm.P4.checked + "&day=" + frm.day.value + "&from=" + frm.fromDate.value + "&to=" + frm.toDate.value + "&uid=" + frm.user_id.value;
       // window.location.href = url;
        var wd = window.open(url);
      }
   }   
  }
  
  function backTomenu()
  {    
    <%= backClick%> ;
  }
  
  function noInteger()
{
	var u = event.srcElement.value ;
	u = u.substring(0,1);
	if(u == '-')
		event.srcElement.value = "";
		//showOWarningDialog("warning", "Data in field is not integer", "OK");
}
</SCRIPT>    
    <%=fileInfoUtil.MasterFootTable()%>
   </body>
   <%@include file="../include/eproErrorAlert.jsp"%>
</HTML>
